package com.skwyb.form.service.admin;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.skwyb.form.bean.dto.SysRoleAdmin;
import com.skwyb.form.mapper.SysRoleAdminMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Administrator
 */
@Log4j2
@Service
@RequiredArgsConstructor
public class RoleAdminService extends ServiceImpl<SysRoleAdminMapper, SysRoleAdmin> {

    /**
     * 根据角色查询admin
     *
     * @param roleId roleId
     * @return adminIDs
     */
    public String getAdminIds(String roleId) {
        List<SysRoleAdmin> adminList = list(Wrappers.lambdaQuery(new SysRoleAdmin().setRoleId(roleId)));
        return adminList.stream().map(SysRoleAdmin::getAdminId).collect(Collectors.joining(","));
    }
}
